﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:WhileAwayWpf" x:Class="WhileAwayWpf.MessageLogUserControl"
    Height="360" Width="250" Unloaded="UserControl_Unloaded">

    <UserControl.Resources>
    	<local:BooleanVisibilityConverter x:Key="BooleanVisibilityConverter"/>
        <!-- create a data template to display the desired XML node values -->

        <DataTemplate x:Key="MessageDataTemplate">
            <DockPanel Visibility="{Binding IsPrivate, Converter={StaticResource BooleanVisibilityConverter}, ConverterParameter=Inverted, Mode=Default}">
                <StackPanel Margin="5,5,5,5" Background="AliceBlue">
                    <TextBlock FontSize="12" FontWeight="Bold" Foreground="DarkBlue" Text="{Binding Message}"/>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock FontSize="10" Foreground="LightGray" Text="by " />
                        <TextBlock FontSize="10" Foreground="LightGray" Text="{Binding Sender}" />
                    </StackPanel>
                </StackPanel>
            </DockPanel>
        </DataTemplate>

        <Storyboard x:Key="GlowStoryboardMessage">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="GlowEffectMessage" Storyboard.TargetProperty="GlowSize">
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="10"/>
                <SplineDoubleKeyFrame KeyTime="00:00:01.0000000" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
        <Storyboard x:Key="GlowStoryboardName">
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="GlowEffectName" Storyboard.TargetProperty="GlowSize">
                <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="10"/>
                <SplineDoubleKeyFrame KeyTime="00:00:01.0000000" Value="0"/>
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>

    </UserControl.Resources>

    <Border CornerRadius="10,10,10,10" BorderThickness="5" Margin="1" Padding="5" Background="LightCyan">
        <DockPanel LastChildFill="True" >
            <TextBlock DockPanel.Dock="Top" TextAlignment="Center" FontSize="22"><Run Text="Leave me a message!"/></TextBlock>
            <Border DockPanel.Dock="Top" CornerRadius="10,10,10,10" BorderThickness="5" Margin="1" Padding="5">
                <Border.Background>
                    <LinearGradientBrush >
                        <GradientStop Color="Aqua" Offset="0"/>
                        <GradientStop Color="LightBlue" Offset=".5"/>
                    </LinearGradientBrush>
                </Border.Background>
                
                <DockPanel x:Name="stackPanel1" LastChildFill="True">
                    <Label DockPanel.Dock="Top" x:Name="label1" Content="Your name" />
                    <Border DockPanel.Dock="Top" x:Name="borderName" BorderThickness="2" CornerRadius="5,5,5,5" Margin="2">
                        <Border.BitmapEffect>
                            <OuterGlowBitmapEffect x:Name="GlowEffectName" GlowColor="Blue" GlowSize="0" Noise=".8" Opacity="0.4" />
                        </Border.BitmapEffect>
                        <TextBox x:Name="textBoxName" Text="{Binding Sender}" />
                    </Border>
                    <Label DockPanel.Dock="Top" x:Name="label2" Content="Your message" />
                    <Border DockPanel.Dock="Top" x:Name="borderMessage"   BorderThickness="2" CornerRadius="5,5,5,5" Margin="2">
                        <Border.BitmapEffect>
                            <OuterGlowBitmapEffect x:Name="GlowEffectMessage" GlowColor="Blue" GlowSize="0" Noise=".8" Opacity="0.4" />
                        </Border.BitmapEffect>
                        <TextBox x:Name="textBoxMessage" Text="{Binding Message}"/>
                    </Border>
                    <CheckBox DockPanel.Dock="Top" x:Name="checkBoxPrivate" IsChecked="{Binding IsPrivate}" Content="Private?"/>
                    <Button DockPanel.Dock="Top" Margin="20,5,20,5" x:Name="buttonLeaveMessage" Click="buttonLeaveMessage_Click" Content="Leave your message!"/>
                    <Border DockPanel.Dock="Bottom" x:Name="border5" BorderThickness="2" Margin="3,3,3,3" CornerRadius="5" >
                        <ListBox x:Name="listBoxMessages" ItemTemplate="{StaticResource MessageDataTemplate}"/>
                    </Border>
                </DockPanel>
            </Border>
        </DockPanel>
    </Border>
</UserControl>
